
package Attributes;

public class SimpleAttribute extends Attribute {
    
    /*
     * Clase SimpleAttribute
     *
     * Extiende de la clase Attribute, para representar atributos simples, que
     * contienen un nombre, un valor y su ponderacion asociada.
     */

    private String name;
    protected double value;
    protected double factor;
    private double umbral;
    private int flag;

    public SimpleAttribute(String name, double value, double factor) {
        setName(name);
        this.value = value;
        this.factor = factor;
        this.umbral = 0d;
    }

    @Override
    public final String getName() {
        return name;
    }

    @Override
    public double getValue() {
        return factor * value;
    }

    @Override
    public double getFactor() {
        return factor;
    }

    @Override
    public final void setName(String name) {
        this.name = name;
    }

    @Override
    public void setValue(double value) {
        if (this.value != value) {
            this.value = value;
            notifyObservers();
        }
    }

    @Override
    public void setFactor(double factor) {
        if (this.factor != factor) {
            this.factor = factor;
            setChanged();
            notifyObservers();
        }
    }

    public void setUmbral(double umbral, int flag) {
        //if (this.umbral != umbral || this.flag != flag) {
            this.umbral = umbral;
            this.flag = flag;
            setChanged();
            notifyObservers();
        //}
    }

    @Override
    public String toString() {
        return Double.toString(value);
    }

    public boolean isExcluyente() {
        return value < umbral;
    }
}
